/* 遍历children节点*/

import React,{ReactNode} from "react";
import {isFragment} from 'react-is';

/**
 * 遍历 children 节点
 */
 export function traverseReactNode(children: ReactNode, fn: (child: ReactNode, index: number) => void): void {
    let i = 0;
    const handle = (children:ReactNode) =>{
        React.Children.forEach(children,child=>{
            if(!isFragment(child)){
                fn(child,i);
              i= i+1;
            }else{
                handle(child.props.Children);
            }
        })
    }
    handle(children);


  }
  /*
  * 判断数据类型
  */
 type Type = 'Object' | 'Array' | 'Function' | 'Boolean' | 'Number' | 'String' | 'Undefined' | 'Null'| 'Symbol'
 export   const jugeType= (obj,type:Type):boolean => Object.prototype.toString.call(obj) === `[object ${type}]` 
   
 
;
 
  